<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
	<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
	<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ include file="../../common/base.jsp"%>
<%
	response.setCharacterEncoding("utf-8");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Insert title here</title>
<link href="${path }/dist/css/bootstrap.css" rel="stylesheet">


<!-- Button -->
<link href="${path }/dist/css/compiled/elements.css" rel="stylesheet">
<!-- libraries -->
<link rel="stylesheet" type="text/css"  href="${path }/dist/css/font-awesome.css">
<!-- this -->
<link rel="stylesheet" type="text/css" href="${path }/dist/css/app.css">
<!-- 右键菜单插件 -->
<link rel="stylesheet" type="text/css" href="${path }/dist/css/smartMenu.css">

<link href='${path }/dist/css/zTreeStyle/zTreeStyle.css' rel='stylesheet' />
<link href="${path }/dist/css/bootstrap-datetimepicker.min.css" rel="stylesheet"><%--时间日期工具 --%>

<link rel="stylesheet" type="text/css" href="${path }/back/ifrom.css">
<script src="${path }/dist/js/jquery.min.js"></script>
<script src='${path }/dist/js/bootstrap.min.js'></script>
<script src='${path }/dist/js/jquery-smartMenu.js'></script>
<script src='${path }/dist/js/jquery.ztree.core-3.5.js'></script>
<script src='${path }/dist/js/jquery.ztree.excheck-3.5.js'></script>
<script src='${path }/dist/js/jquery.ztree.exedit-3.5.js'></script>
<script src="${path }/dist/js/bootstrap-datetimepicker.min.js"></script>
<script src="${path }/dist/js/bootstrap-datetimepicker.zh-CN.js"></script>

<style>
.left_tree{
	height: 400px;
	overflow: auto;
	border: 1px solid #ccc;
	 border-radius: 5px;
}
#pad-wrapper h3{
	font-family: "黑体";
}
.my_modal{
	position: absolute;
	height: 200px;
	width: 600px;
	display:none;
	left: 20%;
	top: 10%;
}
.my_input {
  width: 150px;
  height: 34px;
  padding: 6px 12px;
  font-size: 14px;
  line-height: 1.428571429;
  color: #555555;
  vertical-align: middle;
  background-color: #ffffff;
  border: 1px solid #cccccc;
  border-radius: 4px;
  -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
  -webkit-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
  transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
}
.my_input:focus {
  border-color: #66afe9;
  outline: 0;
  -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, 0.6);
  box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, 0.6);
}
.ztree [class^="icon-"],
.ztree [class*=" icon-"]{
	color:#000;
}
.ztree span.icon-home{
	font-size: 20px;
	
}

#staff_table th{
	padding: 10px 0;
	cursor: pointer;

}
#staff_table th:hover{
text-decoration:  underline;

}
#staff_table td, #staff_table th{
	padding: 5px 3px;
	vertical-align:middle;
	min-width:70px;
	word-break: keep-all;/*强制不换行*/
	text-align: center;
} 
#menuContent .ztree {margin-top: 10px;border: 1px solid #617775;background: #f0f6e4;width:220px;height:360px;overflow-y:scroll;overflow-x:auto;}
</style>
</head>
<body>
<div id="pad-wrapper">
	<div class="row head" >
	<div class="col-md-12 ">
			<h3>折旧管理<em><small>点击左边目录树出现在用资产，点击相应按钮进行操作</small></em></h3>
			</div>
	</div>
	<hr>
	<div class="row">
		<div class="col-md-2">
			<div class="row">
				<div class="col-md-12 left_tree">
					<div class="ztree" id="allTree"></div>
				</div>
				<div class="col-md-12">
					统计部分
				</div>
			</div>
		</div>
		<div class="col-md-10 table-wrapper users-table">
			<div class="row filter-block">
				<div class="pull-left" style="margin-left: 10px;">时间：<fmt:formatDate value="${date}" pattern="yyyy-MM-dd"/></div>
				<div class="pull-right">
					<a class="btn-flat success new-product" href="javascript:void(0);"><i class="icon-cloud-download"></i><span>查看</span></a>
					<a  class="btn-flat success new-product" onclick="fold()"><i class="icon-time"></i><span>计提折旧</span></a>
				</div><!-- 按钮组 -->
			</div>
			<div class="row" style="margin-top: 5px;">
				<div class="col-md-12" style="overflow-x: auto;">
				<div style="width: 1500px; height: 500px;">
				<table class="table-striped table-bordered" id="staff_table" >
						<thead >
							<tr id="table_title" class="table_title">
								<th class="sortable" ><span class="line"></span><span >使用部门</span></th>
								<th class="sortable" ><span class="line"></span><span >资产编号</span ></th>
								<th class="sortable" ><span class="line"></span><span >类别名称</span></th>
								<th class="sortable" ><span class="line"></span><span >资产名称</span></th>
								<th class="sortable" ><span class="line"></span><span >资产规格</span></th>
								<th class="sortable" ><span class="line"></span><span >是否计提</span></th>
								<th class="sortable" ><span class="line"></span><span >资产单价</span></th>
								<th class="sortable" ><span class="line"></span><span >折旧方式</span></th>
								<th class="sortable" ><span class="line"></span><span >使用年限</span></th>
								<th class="sortable" ><span class="line"></span><span >净残值率</span></th>
								<th class="sortable" ><span class="line"></span><span >月提折旧</span></th>
								<th class="sortable" ><span class="line"></span><span >累计折旧</span></th>
								<th class="sortable" ><span class="line"></span><span >净值</span></th>
								<th class="sortable" ><span class="line"></span><span >购置日期</span></th>
								<th class="sortable" ><span class="line"></span><span >登记日期</span></th>
							</tr>
						</thead>
						<tbody id="node_tbody" >
						</tbody>
						</table>
						</div>
				</div>
			</div>
		</div>
	</div>
</div>


	<script type="text/javascript">
	//alert(cutStr(18000+""));
	var setting = {
			view: {
				selectedMulti: false,//多选
				showLine: true,
				nameIsHTML: true
			}, callback : {
				beforeClick : beforeClick,
			},data:{
				simpleData:{
					enable: true,
				}
			}
		};
	function fold(){

   		var saveURL = "${path}/back/assetsMS!fold?date="+new Date()+"";
    		jQuery.post(saveURL,null,function(data){
    			if(data.info)
    					alert(data.text);
    			window.location.reload(true);
    		},'json'); 
	}
	function beforeClick(treeId, treeNode){
		/* */
		if(treeNode!=null&&treeNode.id>0){
			var data=new Array();
			var target=$("#node_tbody");
			target.empty();//清空
			var saveURL = "${path}/back/assetsMS!getAssetsByfield?date="+new Date()+"";
			data.push({name:"fieldName",value:treeNode.fieldName});
			data.push({name:"name",value:treeNode.field});
			jQuery.post(saveURL,data,function(jsonData){
				if(jsonData!=null){
					addTr(jsonData,treeNode,target);
				}
			},"json"); 
		}else{
			var target=$("#node_tbody");
			target.empty();//清空
			var saveURL = "${path}/back/assetsMS!getAssetsByfield?date="+new Date()+"";
			jQuery.post(saveURL,null,function(jsonData){
				if(jsonData!=null){
					addTr(jsonData,treeNode,target);
				}
			},"json"); 
		}
		return true;
	}
	function addTr(jsonData,treeNode,target){
		for(var j=0;j<jsonData.length;j++){
			var tr_obj=$("<tr data-id='"+jsonData[j].ID+"'>").appendTo(target);
			$("<td>"+jsonData[j].DEPT_NAME+"</td>").appendTo(tr_obj);
			$("<td>"+jsonData[j].A_NUMBER+"</td>").appendTo(tr_obj);
			$("<td>"+jsonData[j].A_CLASS_NAME+"</td>").appendTo(tr_obj);
			$("<td>"+jsonData[j].A_NAME+"</td>").appendTo(tr_obj);
			$("<td>"+jsonData[j].A_SPECIFICATION+"</td>").appendTo(tr_obj);
			$("<td><i class='"+(jsonData[j].ISDEPRECIATION==1?"icon-check":"icon-check-empty")+"'></i></td>").appendTo(tr_obj);
			$("<td>"+outputmoney(jsonData[j].A_UNIT_PRICE.toFixed(2))+"</td>").appendTo(tr_obj);
			$("<td>"+jsonData[j].A_D_M+"</td>").appendTo(tr_obj);//data-dept-id='"+treeNode.id+"'
			$("<td>"+jsonData[j].A_YEARS+"</td>").appendTo(tr_obj);
			$("<td>"+jsonData[j].A_JC_RATE+"%</td>").appendTo(tr_obj);
			$("<td>"+outputmoney(jsonData[j].A_YTD.toFixed(2))+"</td>").appendTo(tr_obj);
			$("<td>"+outputmoney(jsonData[j].A_COUNT_D.toFixed(2))+"</td>").appendTo(tr_obj);
			$("<td>"+outputmoney(jsonData[j].A_J_VALUE.toFixed(2))+"</td>").appendTo(tr_obj);
			$("<td>"+jsonData[j].A_BUY_DATE+"</td>").appendTo(tr_obj);
			$("<td>"+jsonData[j].A_REGISTER_DATA+"</td>").appendTo(tr_obj);
		}
	}
	$(document).ready(function() {
		var saveURL = "${path}/back/tree!getAllTree?date="+new Date()+"";
		jQuery.post(saveURL,null,function(jsonData){
			ztreeobj=$.fn.zTree.init($("#allTree"), setting,jsonData);
			beforeClick(null,null);
		},"json");
		
	});
	//时间日期
	$(".form_datetime").datetimepicker({format: 'yyyy-mm-dd',language:  'zh-CN',weekStart: 1,
        todayBtn:  1,
		autoclose: 1,
		todayHighlight: 1,
		startView: 2,
		forceParse: 0,
        showMeridian: 1,
        minView: 2,
        pickerPosition:"bottom-left"});
	function onBodyDowndept(event){
		if (!($(event.target).parents("#menuContent").length>0)) {
			hidedepttree();
		}
	}



	</script>
	<c:if test="${tip!=null }">
		<script>
			alert("${tip}");
		</script>
	</c:if>
</body>
</html>